package thread;

/**
 * @author zxl
 * @version 1.0
 * @date 2021/10/26 17:44
 * 强制其他线程停止，让自己先执行完毕
 */
public class ThreadJoin {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 20; i++) {
                    System.out.println("vip" + i);
                }
            }
        });
        thread.start();

        for (int i = 0; i < 10; i++) {
            if (i==5){
                thread.join();
            }
            System.out.println("主线程"+i);
        }
    }
}
